package com.example.pjy.controller;

import com.example.pjy.pojo.Result;
import com.example.pjy.pojo.Student;
import com.example.pjy.pojo.Studentin2;
import com.example.pjy.service.Studentin2Service;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/studentin2")
public class Studentin2Controller {
    @Resource
    private Studentin2Service studentin2Service;


    @GetMapping("/selectlist")
    public Result<List<Studentin2>>selectlist(){
        List<Studentin2> st2= studentin2Service.list();
        return Result.success(st2);//结果是数组
    }

    //计算研二学生每人分数
    @PostMapping("/total")
    public Result total(Integer year){
        studentin2Service.calTotalScore(year);
        studentin2Service.calAward(year);
        return Result.success();
    }



    //计算分数后更改研二分数字段
    @PutMapping("/updatest2")
    public Result updatest2(Studentin2 studentin2){
        studentin2Service.updatest2(studentin2);
        return Result.success();
    }


    @GetMapping("/selectbyname")
    public Result<List<Studentin2>> selectbyname(@RequestParam("keyword") String keyword){
        List<Studentin2> st2 = studentin2Service.selectbyname(keyword);
        return Result.success(st2);
    }
}
